<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>统计表模块系统</title>
    <script>
        // 页面加载时设置默认用户信息
        (function() {
            // 设置默认的统计表模块用户信息
            if (!localStorage.getItem('statisticsCurrentUser')) {
                localStorage.setItem('statisticsCurrentUser', JSON.stringify({
                    name: '统计表管理员',
                    role: '统计表管理员'
                }));
                localStorage.setItem('statisticsIsLoggedIn', 'true');
            }
        })();
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #333;
            min-height: 100vh;
        }

        .container {
            display: flex;
            min-height: 100vh;
        }

        /* 左侧侧边栏 */
        .sidebar {
            width: 280px;
            background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 50%, #3b82f6 100%);
            color: white;
            padding: 0;
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
            position: fixed;
            height: 100vh;
            overflow-y: auto;
        }

        .sidebar-header {
            padding: 30px 20px;
            background: rgba(255, 255, 255, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            margin-bottom: 20px;
            text-align: center;
        }

        .sidebar-title {
            font-size: 22px;
            font-weight: bold;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 8px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 15px 20px;
            color: white;
            text-decoration: none;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 12px;
            border-left: 4px solid transparent;
        }

        .nav-link:hover, .nav-link.active {
            background: rgba(255, 255, 255, 0.1);
            border-left-color: #60a5fa;
            transform: translateX(5px);
        }

        .nav-icon {
            margin-right: 15px;
            font-size: 18px;
        }

        /* 右侧主内容区域 */
        .main-content {
            flex: 1;
            margin-left: 280px;
            padding: 30px;
            background: rgba(255, 255, 255, 0.95);
        }

        .content-header {
            background: white;
            padding: 25px 30px;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        .header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .header-left h1 {
            font-size: 28px;
            color: #1e3a8a;
            margin-bottom: 8px;
        }

        .breadcrumb {
            color: #6b7280;
            font-size: 14px;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-avatar {
            width: 50px;
            height: 50px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            color: white;
        }

        .user-details {
            text-align: right;
        }

        .user-name {
            font-weight: bold;
            color: #1e3a8a;
            margin-bottom: 4px;
        }

        .user-role {
            color: #6b7280;
            font-size: 14px;
        }

        .btn-logout {
            background: #ef4444;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-logout:hover {
            background: #dc2626;
        }

        /* 功能模块样式 */
        .function-module {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
            overflow: hidden;
        }

        .module-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px 30px;
            font-size: 18px;
            font-weight: bold;
        }

        .module-content {
            padding: 30px;
        }

        /* 数据表格样式 */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            border-radius: 10px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .data-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px;
            text-align: left;
            font-weight: 600;
        }

        .data-table td {
            padding: 15px;
            border-bottom: 1px solid #e5e7eb;
        }

        .data-table tr:hover {
            background: #f8fafc;
        }

        .status-badge {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
        }

        .status-completed {
            background: #dcfce7;
            color: #166534;
        }

        .status-ongoing {
            background: #fef3c7;
            color: #92400e;
        }

        .status-cancelled {
            background: #fef2f2;
            color: #dc2626;
        }

        .action-buttons {
            display: flex;
            gap: 8px;
        }

        .btn-action {
            padding: 6px 12px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s ease;
        }

        .btn-action-view {
            background: #3b82f6;
            color: white;
        }

        .btn-action-view:hover {
            background: #2563eb;
        }

        .btn-action-export {
            background: #10b981;
            color: white;
        }

        .btn-action-export:hover {
            background: #059669;
        }

        /* 搜索区域样式 */
        .search-container {
            background: white;
            border-radius: 15px;
            padding: 20px 30px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        .search-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            align-items: end;
        }

        .search-group {
            display: flex;
            flex-direction: column;
        }

        .search-label {
            font-weight: 600;
            color: #374151;
            margin-bottom: 8px;
        }

        .search-input {
            padding: 10px 15px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .search-input:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .search-actions {
            display: flex;
            gap: 10px;
        }

        .btn-search {
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .btn-search-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-search-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-search-secondary {
            background: #6b7280;
            color: white;
        }

        .btn-search-secondary:hover {
            background: #4b5563;
        }

        .btn-export {
            background: #10b981;
            color: white;
        }

        .btn-export:hover {
            background: #059669;
        }

        /* 统计卡片样式 */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: white;
            padding: 25px;
            border-radius: 15px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }

        .stat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .stat-title {
            font-size: 14px;
            color: #6b7280;
            font-weight: 600;
        }

        .stat-icon {
            font-size: 24px;
        }

        .stat-value {
            font-size: 32px;
            font-weight: bold;
            color: #1e3a8a;
            margin-bottom: 10px;
        }

        .stat-change {
            font-size: 14px;
            font-weight: 600;
        }

        .stat-change.positive {
            color: #10b981;
        }

        .stat-change.negative {
            color: #ef4444;
        }

        /* 表格响应式 */
        .table-container {
            overflow-x: auto;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                position: relative;
                height: auto;
            }
            
            .main-content {
                margin-left: 0;
            }
            
            .header-top {
                flex-direction: column;
                gap: 20px;
                text-align: center;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 左侧侧边栏 -->
        <nav class="sidebar">
            <div class="sidebar-header">
                <div class="sidebar-title">统计表模块系统</div>
            </div>
            
            <ul class="nav-menu">
                <li class="nav-item">
                    <a href="#" class="nav-link active" onclick="switchFunction('session-detail')">
                        <span class="nav-icon">📋</span>
                        <span class="nav-text">场次参观明细表</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link" onclick="switchFunction('session-statistics')">
                        <span class="nav-icon">📊</span>
                        <span class="nav-text">场次参观统计表</span>
                    </a>
                </li>
                <li class="nav-item">
                    <a href="life-science-management.html" class="nav-link">
                        <span class="nav-icon">🏠</span>
                        <span class="nav-text">返回主页</span>
                    </a>
                </li>
            </ul>
        </nav>

        <!-- 右侧主内容区域 -->
        <main class="main-content">
            <div class="content-header">
                <div class="header-top">
                    <div class="header-left">
                        <h1>统计表模块</h1>
                        <div class="breadcrumb">生命科学馆管理 > 统计表模块</div>
                    </div>
                    <div class="user-info">
                        <div class="user-avatar">👤</div>
                        <div class="user-details">
                            <div class="user-name" id="current-user-name">统计表管理员</div>
                            <div class="user-role" id="current-user-role">统计表管理员</div>
                        </div>
                        <button class="btn-logout" onclick="logout()">退出登录</button>
                    </div>
                </div>
            </div>

            <!-- 场次参观明细表 -->
            <div id="session-detail-content" class="content-section">
                <div class="function-module">
                    <div class="module-header">场次参观明细表</div>
                    <div class="module-content">
                        <div class="search-container">
                            <div class="search-grid">
                                <div class="search-group">
                                    <label class="search-label">日期范围</label>
                                    <input type="date" class="search-input" id="start-date">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">至</label>
                                    <input type="date" class="search-input" id="end-date">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">场次状态</label>
                                    <select class="search-input" id="session-status">
                                        <option value="">全部状态</option>
                                        <option value="completed">已完成</option>
                                        <option value="ongoing">进行中</option>
                                        <option value="cancelled">已取消</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">讲解员</label>
                                    <select class="search-input" id="guide-filter">
                                        <option value="">全部讲解员</option>
                                        <option value="张老师">张老师</option>
                                        <option value="李老师">李老师</option>
                                        <option value="王老师">王老师</option>
                                        <option value="陈老师">陈老师</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">&nbsp;</label>
                                    <div class="search-actions">
                                        <button type="button" class="btn-search btn-search-primary" onclick="searchDetailTable()">搜索</button>
                                        <button type="button" class="btn-search btn-search-secondary" onclick="clearDetailSearch()">清除</button>
                                        <button type="button" class="btn-search btn-export" onclick="exportDetailTable()">导出</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-container">
                            <table class="data-table">
                                <thead>
                                    <tr>
                                        <th>场次编号</th>
                                        <th>日期</th>
                                        <th>时间段</th>
                                        <th>讲解员</th>
                                        <th>预约人数</th>
                                        <th>实际人数</th>
                                        <th>参观类型</th>
                                        <th>状态</th>
                                        <th>满意度</th>
                                        <th>备注</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="detail-table-body">
                                    <tr>
                                        <td>S20240115001</td>
                                        <td>2024-01-15</td>
                                        <td>09:00-11:00</td>
                                        <td>张老师</td>
                                        <td>25</td>
                                        <td>23</td>
                                        <td>团体参观</td>
                                        <td><span class="status-badge status-completed">已完成</span></td>
                                        <td>4.8</td>
                                        <td>某小学科普活动</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewSessionDetail('S20240115001')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportSingleSession('S20240115001')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>S20240115002</td>
                                        <td>2024-01-15</td>
                                        <td>14:00-16:00</td>
                                        <td>李老师</td>
                                        <td>15</td>
                                        <td>15</td>
                                        <td>个人参观</td>
                                        <td><span class="status-badge status-completed">已完成</span></td>
                                        <td>4.6</td>
                                        <td>散客参观</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewSessionDetail('S20240115002')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportSingleSession('S20240115002')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>S20240116001</td>
                                        <td>2024-01-16</td>
                                        <td>10:00-12:00</td>
                                        <td>王老师</td>
                                        <td>30</td>
                                        <td>28</td>
                                        <td>学校参观</td>
                                        <td><span class="status-badge status-completed">已完成</span></td>
                                        <td>4.9</td>
                                        <td>某中学生物课外实践</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewSessionDetail('S20240116001')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportSingleSession('S20240116001')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>S20240116002</td>
                                        <td>2024-01-16</td>
                                        <td>15:00-17:00</td>
                                        <td>陈老师</td>
                                        <td>20</td>
                                        <td>0</td>
                                        <td>团体参观</td>
                                        <td><span class="status-badge status-cancelled">已取消</span></td>
                                        <td>-</td>
                                        <td>天气原因取消</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewSessionDetail('S20240116002')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportSingleSession('S20240116002')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>S20240117001</td>
                                        <td>2024-01-17</td>
                                        <td>09:30-11:30</td>
                                        <td>张老师</td>
                                        <td>18</td>
                                        <td>18</td>
                                        <td>家庭参观</td>
                                        <td><span class="status-badge status-ongoing">进行中</span></td>
                                        <td>-</td>
                                        <td>亲子科普活动</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewSessionDetail('S20240117001')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportSingleSession('S20240117001')">导出</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 场次参观统计表 -->
            <div id="session-statistics-content" class="content-section" style="display: none;">
                <div class="function-module">
                    <div class="module-header">场次参观统计表</div>
                    <div class="module-content">
                        <!-- 统计概览卡片 -->
                        <div class="stats-grid">
                            <div class="stat-card">
                                <div class="stat-header">
                                    <div class="stat-title">本月总场次</div>
                                    <div class="stat-icon">📅</div>
                                </div>
                                <div class="stat-value">126</div>
                                <div class="stat-change positive">↗ +12.5%</div>
                            </div>
                            <div class="stat-card">
                                <div class="stat-header">
                                    <div class="stat-title">本月参观人数</div>
                                    <div class="stat-icon">👥</div>
                                </div>
                                <div class="stat-value">2,856</div>
                                <div class="stat-change positive">↗ +8.3%</div>
                            </div>
                            <div class="stat-card">
                                <div class="stat-header">
                                    <div class="stat-title">平均满意度</div>
                                    <div class="stat-icon">⭐</div>
                                </div>
                                <div class="stat-value">4.7</div>
                                <div class="stat-change positive">↗ +0.2</div>
                            </div>
                            <div class="stat-card">
                                <div class="stat-header">
                                    <div class="stat-title">取消率</div>
                                    <div class="stat-icon">❌</div>
                                </div>
                                <div class="stat-value">5.2%</div>
                                <div class="stat-change negative">↗ +1.1%</div>
                            </div>
                        </div>

                        <div class="search-container">
                            <div class="search-grid">
                                <div class="search-group">
                                    <label class="search-label">统计周期</label>
                                    <select class="search-input" id="statistics-period">
                                        <option value="daily">日统计</option>
                                        <option value="weekly">周统计</option>
                                        <option value="monthly" selected>月统计</option>
                                        <option value="yearly">年统计</option>
                                    </select>
                                </div>
                                <div class="search-group">
                                    <label class="search-label">开始日期</label>
                                    <input type="date" class="search-input" id="stats-start-date">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">结束日期</label>
                                    <input type="date" class="search-input" id="stats-end-date">
                                </div>
                                <div class="search-group">
                                    <label class="search-label">&nbsp;</label>
                                    <div class="search-actions">
                                        <button type="button" class="btn-search btn-search-primary" onclick="generateStatistics()">生成统计</button>
                                        <button type="button" class="btn-search btn-export" onclick="exportStatistics()">导出统计</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="table-container">
                            <table class="data-table">
                                <thead>
                                    <tr>
                                        <th>统计周期</th>
                                        <th>场次数量</th>
                                        <th>预约人数</th>
                                        <th>实际人数</th>
                                        <th>出席率</th>
                                        <th>取消场次</th>
                                        <th>取消率</th>
                                        <th>平均满意度</th>
                                        <th>主要讲解员</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="statistics-table-body">
                                    <tr>
                                        <td>2024年1月第1周</td>
                                        <td>28</td>
                                        <td>567</td>
                                        <td>523</td>
                                        <td>92.2%</td>
                                        <td>2</td>
                                        <td>7.1%</td>
                                        <td>4.6</td>
                                        <td>张老师</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewWeeklyDetail('2024-W1')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportWeeklyStats('2024-W1')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>2024年1月第2周</td>
                                        <td>32</td>
                                        <td>645</td>
                                        <td>612</td>
                                        <td>94.9%</td>
                                        <td>1</td>
                                        <td>3.1%</td>
                                        <td>4.8</td>
                                        <td>李老师</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewWeeklyDetail('2024-W2')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportWeeklyStats('2024-W2')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>2024年1月第3周</td>
                                        <td>35</td>
                                        <td>712</td>
                                        <td>689</td>
                                        <td>96.8%</td>
                                        <td>0</td>
                                        <td>0.0%</td>
                                        <td>4.9</td>
                                        <td>王老师</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewWeeklyDetail('2024-W3')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportWeeklyStats('2024-W3')">导出</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>2024年1月第4周</td>
                                        <td>31</td>
                                        <td>623</td>
                                        <td>578</td>
                                        <td>92.8%</td>
                                        <td>3</td>
                                        <td>9.7%</td>
                                        <td>4.5</td>
                                        <td>陈老师</td>
                                        <td class="action-buttons">
                                            <button class="btn-action btn-action-view" onclick="viewWeeklyDetail('2024-W4')">查看</button>
                                            <button class="btn-action btn-action-export" onclick="exportWeeklyStats('2024-W4')">导出</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        // 页面加载时设置用户信息
        document.addEventListener('DOMContentLoaded', function() {
            const currentUser = localStorage.getItem('statisticsCurrentUser');
            if (currentUser) {
                const user = JSON.parse(currentUser);
                document.getElementById('current-user-name').textContent = user.name || '统计表管理员';
                document.getElementById('current-user-role').textContent = user.role || '统计表管理员';
            }
        });

        // 功能切换
        function switchFunction(functionName) {
            // 移除所有活动状态
            document.querySelectorAll('.nav-link').forEach(link => {
                link.classList.remove('active');
            });
            
            // 添加活动状态到当前点击的链接
            event.target.closest('.nav-link').classList.add('active');
            
            // 隐藏所有内容
            const allContent = document.querySelectorAll('.content-section');
            allContent.forEach(content => {
                content.style.display = 'none';
            });

            // 显示对应内容
            const targetContent = document.getElementById(functionName + '-content');
            if (targetContent) {
                targetContent.style.display = 'block';
            }
        }

        // 场次参观明细表相关函数
        function searchDetailTable() {
            const startDate = document.getElementById('start-date').value;
            const endDate = document.getElementById('end-date').value;
            const status = document.getElementById('session-status').value;
            const guide = document.getElementById('guide-filter').value;
            
            alert(`搜索明细表: 开始日期: ${startDate}, 结束日期: ${endDate}, 状态: ${status}, 讲解员: ${guide}`);
        }

        function clearDetailSearch() {
            document.getElementById('start-date').value = '';
            document.getElementById('end-date').value = '';
            document.getElementById('session-status').value = '';
            document.getElementById('guide-filter').value = '';
        }

        function exportDetailTable() {
            alert('导出场次参观明细表功能开发中...');
        }

        function viewSessionDetail(sessionId) {
            alert(`查看场次详情 ID: ${sessionId}`);
        }

        function exportSingleSession(sessionId) {
            alert(`导出单个场次 ID: ${sessionId}`);
        }

        // 场次参观统计表相关函数
        function generateStatistics() {
            const period = document.getElementById('statistics-period').value;
            const startDate = document.getElementById('stats-start-date').value;
            const endDate = document.getElementById('stats-end-date').value;
            
            alert(`生成统计表: 周期: ${period}, 开始日期: ${startDate}, 结束日期: ${endDate}`);
        }

        function exportStatistics() {
            alert('导出统计表功能开发中...');
        }

        function viewWeeklyDetail(weekId) {
            alert(`查看周统计详情 ID: ${weekId}`);
        }

        function exportWeeklyStats(weekId) {
            alert(`导出周统计 ID: ${weekId}`);
        }

        // 退出登录
        function logout() {
            localStorage.removeItem('statisticsIsLoggedIn');
            localStorage.removeItem('statisticsCurrentUser');
            window.location.href = 'life-science-management.html';
        }
    </script>
</body>
</html>
